package br.com.fiap.vendas.ws.rest;

import br.com.fiap.vendas.business.delegate.PedidoDelegate;
import br.com.fiap.vendas.business.exception.ServiceException;
import br.com.fiap.vendas.business.vo.PedidoVO;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import java.util.List;

/**
 * Created by jeferson on 1/26/14.
 */
@Path("/pedido")
public class PedidoResource {

    PedidoDelegate pedidoDelegate;

    public PedidoResource() {
        if (pedidoDelegate == null) {
            this.pedidoDelegate = new PedidoDelegate();
        }
    }

    @GET
    @Path("/")
    @Produces(MediaType.APPLICATION_JSON)
    public List<PedidoVO> listarPedidos() {
        try {
            return pedidoDelegate.listarPedidos();
        } catch (ServiceException e) {
            return null;
        }
    }

}
